<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}


$queryString = "
SELECT 
  id, 
  str_category,
  code,
  fullname,
  location,
  quantity,
  price,
  cost
FROM 
  warehouse_product 
WHERE fullname LIKE '%" . $_GET['word_search'] . "%' 
ORDER BY str_category ASC    
LIMIT 10 OFFSET " . ($_GET["pag"] * 10);


$query = pg_query($connect, $queryString);
if (!$query) {
    echo 'query : ';
    return false;
}
$arrRegistros = pg_fetch_all($query);
echo json_encode($arrRegistros);
$num_fields = pg_num_fields($query);
$num_rows = pg_num_rows($query);

pg_close($connect);
